<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script>
			function $$(id){
				return document.getElementById(id)
			}
			window.onload=function(){
				var cnv=$$("canvas")
				var cxt=cnv.getContext("2d")
				cxt.save()
				cxt.beginPath()
				cxt.arc(70,70,50,0,360*Math.PI/180,true)
				cxt.closePath()
				cxt.stroke()
				cxt.clip()
				var  image=new Image()
				image.src="img/2.jpeg"
				image.onload=function(){
					cxt.drawImage(image,10,20)
				}
				$$("btn").onclick=function(){
					cxt.restore()
					cxt.clearRect(0,0,cnv.width,cnv.height)
					var image=new Image()
					image.src="img/1.png"
					image.onload=function(){
						cxt.drawImage(image,10,20)
					}
				}
			}
		</script>
	</head>
	<body>
		<canvas id="canvas" width="200"height="160"style="border: 1px dashed;"></canvas><br />
		<input id="btn" type="button" value="恢复"/>
	</body>
</html>
